package cn.yueranzs.response;

/**
 * @author yueranzs
 * @date 2021-11-01 10:42
 */
public enum ResultCode implements CustomizeResultCode {

    /* 成功 */
    SUCCESS(200, "成功"),

    /* 默认失败 */
    COMMON_FAIL(999, "失败"),

    /* 参数错误：1000～1999 */
    PARAM_NOT_VALID(1001, "参数无效"),
    PARAM_IS_BLANK(1002, "参数为空"),
    PARAM_TYPE_ERROR(1003, "参数类型错误"),
    PARAM_NOT_COMPLETE(1004, "参数缺失"),

    /*部门错误*/
    DEPARTMENT_NOT_EXIST(3007, "部门不存在"),
    DEPARTMENT_ALREADY_EXIST(3008, "部门已存在"),
    DEPARTMENT_NOT_ID(3009, "请输入部门编号"),

    /*响应码*/
    SAVESUCCESS(20000,"保存成功"),
    SAVEERROR(20001,"保存失败"),
    UPDATESUCCESS(20002,"修改成功"),
    UPDATEERROR(20003,"修改失败"),
    DELETESUCCESS(20004,"删除成功"),
    DELETEERROR(20005,"删除失败"),
    NODELETE(1,"有效"),
    DELETE(0,"删除"),

    /* 业务错误 */
    NO_PERMISSION(3001, "没有权限"),

    /*运行时异常*/
    ARITHMETIC_EXCEPTION(9001,"算数异常");


    private Integer code;

    private String message;

    ResultCode(Integer code,String message){
        this.code = code;
        this.message = message;
    }

    /**
     * 获取错误状态码
     *
     * @return 错误状态码
     */
    @Override
    public Integer getCode() {
        return code;
    }

    /**
     * 获取错误信息
     *
     * @return 错误信息
     */
    @Override
    public String getMessage() {
        return message;
    }
}
